<template>
  <t-form ref="form" :data="formData" layout="inline">
    <t-form-item label="合同名称">
      <t-input
        v-model="formData.name"
        placeholder="请输入合同名称"
        clearable
        @enter="handleSearch"
      />
    </t-form-item>
    <t-form-item label="合同类型">
      <t-select v-model="formData.type" placeholder="请选择合同类型" clearable>
        <t-option value="1">主合同</t-option>
        <t-option value="2">子合同</t-option>
      </t-select>
    </t-form-item>
    <t-form-item>
      <t-button theme="primary" @click="handleSearch">搜索</t-button>
      <t-button theme="default" @click="handleReset" style="margin-left: 8px">重置</t-button>
    </t-form-item>
  </t-form>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const emit = defineEmits(['search']);

const formData = ref({
  name: '',
  type: '',
});

const handleSearch = () => {
  emit('search', { ...formData.value });
};

const handleReset = () => {
  formData.value = {
    name: '',
    type: '',
  };
  handleSearch();
};
</script> 